package org.smart4j.plugin.security.password;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.CredentialsMatcher;
import org.smart4j.framework.util.CodecUtil;

/**
 * @author djw E-mail:***@***.com
 * @version 创建时间：2017/10/29 21:51
 */
public class Md5CredentialsMatcher implements CredentialsMatcher{

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        String submitted=String.valueOf(((UsernamePasswordToken)token).getPassword());
        String encrypted=String.valueOf(info.getCredentials());

        return CodecUtil.md5(submitted).equals(encrypted);
    }
}
